import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'

export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src')
    }
  },
  server: {
    host: "0.0.0.0",
    cors: true,
    proxy: {
      '/api/audio': {
        target: 'https://www.soundhelix.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api\/audio/, '')
      },
      '/api': {
        target: 'https://uniqueker.top/connect.php', 
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
    },
  },
  // 添加生产环境配置
  build: {
    outDir: 'dist',
    assetsDir: 'assets',
    // 如果需要兼容旧浏览器，可以设置目标浏览器
    target: 'es2015',
    // 生产环境移除console和debugger
    minify: 'terser',
    terserOptions: {},  // 使用默认配置
    esbuild: {
      drop: ['console', 'debugger']
    },
  }
})

